class MessagesIndicator extends St.Icon {
_init() {
super._init({
- icon_name: 'message-indicator-symbolic',
icon_size: 16,
visible: false,
y_expand: true,
});
this._sources = [];
+ this._count = 0;
+ this._doNotDisturb = false;
+
+ this._settings = new Gio.Settings({
+ schema_id: 'org.gnome.desktop.notifications',
+ });
+ this._settings.connect('changed::show-banners', this._sync.bind(this));
Main.messageTray.connect('source-added', this._onSourceAdded.bind(this));
Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this));
let sources = Main.messageTray.getSources();
sources.forEach(source => this._onSourceAdded(null, source));
+
+ this.connect('destroy', () => {
+ this._settings.run_dispose();
+ this._settings = null;
+ });
}
_onSourceAdded(tray, source) {
_updateCount() {
let count = 0;
this._sources.forEach(source => (count += source.unseenCount));
- count -= Main.messageTray.queueCount;
+ this._count = count - Main.messageTray.queueCount;
- this.visible = count > 0;
+ this._sync();
+ }
+
+ _sync() {
+ let doNotDisturb = !this._settings.get_boolean('show-banners');
+ this.icon_name = doNotDisturb
+ ? 'notifications-disabled-symbolic'
+ : 'message-indicator-symbolic';
+ this.visible = doNotDisturb || this._count > 0;
}
});